local xmake_opts = {
  -- Configuration when saving `xmake.lua`
  on_save = {
    -- Reload project information
    reload_project_info = false,
    -- Configuration for generating `compile_commands.json`
    lsp_compile_commands = {
      enable = true,
      -- Directory name (relative path) for output file
      output_dir = "build",
    },
  },
}

local p_xmake = {
  "Mythos-404/xmake.nvim",
  version = "^3",
  lazy = true,
  event = "BufReadPost",
  config = true,
  opts = xmake_opts,
}

local lualine_y_new_opts = {
  function()
    if not vim.g.loaded_xmake then
      return ""
    end
    local Info = require("xmake.info")
    if Info.mode.current == "" then
      return "XMake: Off"
    end
    if Info.target.current == "" then
      return "Xmake: Not Select Target"
    end
    return ("%s(%s)"):format(Info.target.current, Info.mode.current)
  end,
  cond = function()
    return vim.o.columns > 50
  end,
}

local p_lualine = {
  "nvim-lualine/lualine.nvim",
  event = "VeryLazy",
  -- the opts function can also be used to change the default opts:
  opts = function(_, opts)
    table.insert(opts.sections.lualine_x, {
      function()
        return "😄"
      end,
      cond = function()
        return vim.o.columns > 50
      end,
    })
    table.insert(opts.sections.lualine_y, lualine_y_new_opts)
  end,
}

return {
  p_xmake,
  p_lualine,
}
